package com.alibaba.otter.manager.web.resource;

import com.alibaba.otter.manager.biz.config.record.LogRecordService;
import com.alibaba.otter.manager.biz.config.record.dto.LogRecordQueryDTO;
import com.alibaba.otter.manager.web.dto.RestResponse;
import com.alibaba.otter.manager.web.utils.PaginationUtil;
import com.alibaba.otter.shared.common.model.config.record.LogRecord;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * otter 日志服务
 */
@RequestMapping("/api/v1/log-record")
@RestController
public class LogRecordResource {


    private final LogRecordService logRecordService;

    public LogRecordResource(LogRecordService logRecordService) {
        this.logRecordService = logRecordService;
    }



    @GetMapping("logs")
    public RestResponse<List<LogRecord>> logRecords(LogRecordQueryDTO queryDTO, Pageable page) {
        return PaginationUtil.pageHttpResponse(logRecordService.pageLogs(queryDTO,page));
    }
}
